<?php

namespace App\Console;

use App\Console\Commands\OrderCancelCommand;
use App\Console\Commands\WechatPushCourseBeingStartCommand;
use App\Console\Commands\WechatPushCourseBeingEndCommand;
use App\Console\Commands\WechatPushLessonBeingSendCommand;
use Illuminate\Console\Scheduling\Schedule;
use Laravel\Lumen\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        WechatPushLessonBeingSendCommand::class,
        WechatPushCourseBeingEndCommand::class,
        WechatPushCourseBeingStartCommand::class,
        OrderCancelCommand::class
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        // 订单取消
        $schedule->command('command:order-cancel')->cron(env('SCHEDULE_ORDER_CANCEL', '* * * * *')); // '0 20 * * 1,4'
        // 每周六，周四20:00执行
        // 在读等级课程推送完后，已购买下一等级课程时，在推送完当前课程，下一个课程上课的前一天晚上20：00进行新课程的开课通知
        $schedule->command('command:wechat-push-course-being-start')->cron(env('SCHEDULE_COURSE_BEING_START', '*/2 * * * *')); // '0 20 * * 4,6'
        // 每周日，周五15:00执行
        // 用户购买的课程最后一节课的前一周的下午15:00进行推送；
        $schedule->command('command:wechat-push-course-being-end')->cron(env('SCHEDULE_COURSE_BEING_END', '*/2 * * * *')); // '0 15 * * 0,5'
        // 每周日，周五18:00执行
        $schedule->command('command:wechat-push-lesson-being-send')->cron(env('SCHEDULE_LESSON_BEING_SEND', '*/3 * * * *')); // '0 18 * * 0,5'
    }
}
